﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;
using EMS20.Entity;
using EMS20.IDataAccessLayer;
using EMS20.DALFactory;

namespace EMS20.BusinessLogicLayer
{
    /// <summary>
    /// BLL Layer For dbo.Category.
    /// </summary>
    public class CategoryBLLBase
    {
		#region ----------变量定义----------
		///<summary>
		///
		///</summary>
		public static readonly ICategoryDataAccessLayer _dal=DataAccessFactory.Create_Category();
		#endregion
		
		#region ----------构造函数----------
		/// <summary>
		/// 构造函数
		/// </summary>
		public CategoryBLLBase()
		{
		}
		#endregion

        #region ----------函数定义----------
		#region 添加更新删除
		/// <summary>
		/// 向数据库中插入一条新记录。
		/// </summary>
		/// <param name="oCategoryInfo">Category??</param>
		/// <returns>新插入记录的编号</returns>
		public static int Create_CategoryInsert(CategoryEntity oCategoryInfo)
		{
			// Validate input
			if (oCategoryInfo == null)
				return 0;
			// Use the dal to insert a new record 
			return _dal.Create_CategoryInsert(oCategoryInfo);
		}
		/// <summary>
		/// 向数据库中插入一条新记录。带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
		/// <param name="oCategoryInfo">Category实体</param>
		/// <returns>新插入记录的编号</returns>
		public static int Create_CategoryInsert(SqlTransaction sp,CategoryEntity oCategoryInfo)
		{
			if (oCategoryInfo == null)
				return 0;
			// Use the dal to insert a new record 
			return _dal.Create_CategoryInsert(sp,oCategoryInfo);
		}
		/// <summary>
		/// 向数据表Category更新一条记录。
		/// </summary>
		/// <param name="oCategoryInfo">oCategoryInfo</param>
		/// <returns>影响的行数</returns>
		public  static void Create_CategoryUpdate(CategoryEntity oCategoryInfo)
		{
            // Validate input
			if (oCategoryInfo==null)
				return;
			// Use the dal to update a new record 
			_dal.Create_CategoryUpdate(oCategoryInfo);
		}
		/// <summary>
		/// 向数据表Category更新一条记录。带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
		/// <param name="oCategoryInfo">oCategoryInfo</param>
		/// <returns>影响的行数</returns>
		public static int Create_CategoryUpdate(SqlTransaction sp,CategoryEntity oCategoryInfo)
		{
			// Validate input
			if (oCategoryInfo==null)
				return 0;
			// Use the dal to update a new record 
			return _dal.Create_CategoryUpdate(sp,oCategoryInfo);
		}
		
		/// <summary>
		/// 删除数据表Category中的一条记录
		/// </summary>
	    /// <param name="c_id">c_id</param>
		/// <returns>影响的行数</returns>
		public static int Create_CategoryDelete(int c_id)
		{
			// Validate input
			if(c_id<0)
				return 0;
			return _dal.Create_CategoryDelete(c_id);
		}
		/// <summary>
		/// 删除数据表Category中的一条记录,带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
	    /// <param name="c_id">c_id</param>
		/// <returns>影响的行数</returns>
		public static int Create_CategoryDelete(SqlTransaction sp,int c_id)
		{
			// Validate input
			if(c_id<0)
				return 0;
			return _dal.Create_CategoryDelete(sp,c_id);
		}
		#endregion
		
        /// <summary>
		/// 得到 category 数据实体
		/// </summary>
		/// <param name="c_id">c_id</param>
		/// <returns>category 数据实体</returns>
		public static CategoryEntity Get_CategoryEntity(int c_id)
		{
			// Validate input
			if(c_id<0)
				return null;

			// Use the dal to get a record 
			return _dal.Get_CategoryEntity(c_id);
		}
		
		/// <summary>
		/// 得到数据表Category所有记录
		/// </summary>
		/// <returns>实体集</returns>
		public static IList< CategoryEntity> Get_CategoryAll()
		{
			// Use the dal to get all records 
			return _dal.Get_CategoryAll();
		}
			
		
		/// <summary>
        /// 检测是否存在根据主键
        /// </summary>
        /// <param name="c_id">c_id</param>
        /// <returns>是/否</returns>
		public static bool IsExistCategory(int c_id)
		{
			return _dal.IsExistCategory(c_id);
		}

        #endregion
		
		
    }
}

